package com.TTBook.Interceptor;
/**************************************************************************
 * Licensed Material - Property of ShangHai i2Finance.                    *
 * Copyright (c) ShangHai I2Finance Inc. 2009-2012-All rights reserved.   * 
 * (<http://www.i2finance.net>)                                           *
 *                                                                        *
 * This file contains proprietary intellectual property of                *
 * ShangHai i2Finance Inc. The contents of and information in this file   *
 * is only to be used in conjunction with a valid i2Shopping license      *
 * as specified in the  i2Shopping  license agreement. All other use      *
 * is prohibited.                                                         *
 **************************************************************************/


import java.sql.Connection;

import net.sf.log4jdbc.ConnectionSpy;
import net.sf.log4jdbc.SpyLogFactory;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
/**
 * 
 * @author Frank
 *
 * <b>Class Description:</b><br>
 * 包装数据库连接的类，用于协助log4jdbc输出SQL�?
 */
public class DataSourceSpyInterceptor implements MethodInterceptor {  
  
      
    public Object invoke(MethodInvocation invocation) throws Throwable {  
        Object result = invocation.proceed();  
        if(SpyLogFactory.getSpyLogDelegator().isJdbcLoggingEnabled()) {  
            if(result instanceof Connection) {  
                Connection conn = (Connection)result;  
                return new ConnectionSpy(conn);  
            }  
        }  
        return result;  
    }  
  
}  
